<template>
	<view class="content">
		<view class="qa-title" v-if="qa.from == qa">{{qaTitle}}</view>
		<u-parse :content="content"></u-parse>
	</view>
</template>

<script>
	import {
		getQaById,
		getBaseSet,
		getQa
	} from '@/api/common.js'
	export default {
		data() {
			return {
				content: '',
				from: '',
				qaId: '',
				qaTitle: '',
				titleMap: {
					privacy: {
						name: '用户协议',
						type: 1
					},
					service: {
						name: '隐私政策',
						type: 2
					}
				}
			}
		},
		onLoad(option) {
			this.from = option.from
			// 问答详情
			if (this.from == 'qa') {
				uni.setNavigationBarTitle({
					title: '详情'
				})
				this.qaId = option.qaId
				this.getQaById()
			} else {
				uni.setNavigationBarTitle({
					title: this.titleMap[option.from].name
				})
				this.getBaseSet()
			}

		},
		methods: {
			getQaById() {
				getQaById(this.qaId).then(res => {
					this.qaTitle = res.data.qaTitle;
					this.content = res.data.qaContent
				})
			},
			getBaseSet() {
				getBaseSet(this.titleMap[this.from].type).then(res => {
					this.content = res.data.bsContent
				})
			}
		}
	}
</script>

<style lang="scss">
	
	.qa-title{
		padding: 30rpx;
		font-size: 32rpx;
		padding-left: 0;
		font-weight: bold;
	}
	
	.content {
		padding: 20rpx 30rpx;
	}
</style>